cmake_minimum_required(VERSION 2.8)
project(TEST)

set(LOG4CPP C:/chenchang/dev/log4cpp)

include_directories(${LOG4CPP}/include)

if (CMAKE_CL_64)
    set(ARCH X64)
else (CMAKE_CL_64)
    set(ARCH X86)
endif (CMAKE_CL_64)

link_libraries(${LOG4CPP}/bld/${ARCH}/$<$<CONFIG:Debug>:Debug>$<$<NOT:$<CONFIG:Debug>>:Release>/log4cpp$<$<CONFIG:Debug>:d>.lib)

add_executable(main main.cpp)
target_link_libraries(main Ws2_32.lib)

add_custom_command(TARGET main POST_BUILD        # Adds a post-build event to MyTest
#    COMMAND ${CMAKE_COMMAND} -E copy_if_different  # which executes "cmake - E copy_if_different..."
#        "${LOG4CPP}/bld/${ARCH}/$<$<CONFIG:Debug>:Debug>$<$<NOT:$<CONFIG:Debug>>:Release>/log4cpp$<$<CONFIG:Debug>:d>.dll"      # <--this is in-file
#        $<TARGET_FILE_DIR:main>                 # <--this is out-file path
    COMMAND ${CMAKE_COMMAND} -E copy_if_different  # which executes "cmake - E copy_if_different..."
        "${CMAKE_CURRENT_SOURCE_DIR}/log4cpp.conf"      # <--this is in-file
        ${CMAKE_CURRENT_BINARY_DIR})                 # <--this is out-file path
